function fn1(a, b, c) {
  console.log('this', this);
  console.log(a, b, c);
  return 'this is fn1'
}


// 模拟bind
Function.prototype.bind1 = function () {
  // 将参数拆解为数组
  const args = Array.prototype.slice.call(arguments) // 将类数组变为数组
  // 获取 this (数组第一项)
  const t = args.shift()

  // 当前fn1.bind(...)中的fn1
  const self = this
  return function() {
    return self.apply(t, args)
  }
}

Function.prototype.bind2 = function ()  {
  const args = Array.prototype.slice.call(arguments)

  const t = args.shift()
  const self = this
  return function () {
    return self.apply(t, args)
  }
}
const fn2 = fn1.bind2({x : 100}, 10, 20, 30)
const res = fn2()
console.log(res)

